
var slideShow = document.getElementById("slideshow");
var imgList = document.getElementById("imglist");
var imgs = imgList.children;
var dotList = document.getElementById("dotlist");
var dots = dotlist.children;
var pre = document.getElementById("pre");
var next = document.getElementById("next");
var duration = 3000; // 设置轮播时间间隔
var Index = 0;
var count = imglist.children.length; // 获取图片数量
var timer; // 设置一个计时器

window.onload = function () {
  imgList.children[0].classList.add("appear"); // 初始时显示第一幅图片
  dotList.children[0].classList.add("appear"); // 初始时第一个点为白色

  //为每个点添加单击处理函数
  for (var i = 0; i < dots.length; i++) {
    dots[i].index = i;
    dots[i].onclick = changeMe;
  }

  //启动动画自动播放
  timer = setInterval(rotate, duration);

  // 鼠标移到图片上面时,停止动画
  slideShow.onmouseover = function (event) {
    clearInterval(timer);
  };

  // 鼠标离开图片上面时,启动动画
  slideShow.onmouseout = function (event) {
    timer = setInterval(rotate, duration);
  };

  //左右播放图片
  pre.onclick = preImg;
  next.onclick = nextImg;
}

//改变图片和点的当前状态（通过 添加 或 移除 appear 属性）
function change() {
  for (var i = 0; i < dots.length; i++) {
    dots[i].classList.remove("appear");
    imgs[i].classList.remove("appear");
  }
  dots[Index].classList.add("appear");
  imgs[Index].classList.add("appear");
}

//循环切换图片
function rotate() {
  Index++;
  if (Index == count) {
    Index = 0;
  }
  change();
}

//切换上一幅图片
function preImg() {
  Index--;
  if (Index < 0) {
    Index = count - 1;
  }
  change();
}

//切换下一幅图片
function nextImg() {
  Index++;
  if (Index == count) {
    Index = 0;
  }
  change();
}

//单击某个圆点,切换到相应图片
function changeMe() {
  Index = this.index;
  change();
}




{/* <script language="javaScript"> */ }
// now = new Date(), hour = now.getHours()
// if (hour < 6) { document.write(" 凌晨好!朋友!") }
// else if (hour < 9) { document.write("早上好,朋友!") }
// else if (hour < 12) { document.write("上午好,朋友!") }
// else if (hour < 14) { document.write("中午好,朋友!") }
// else if (hour < 17) { document.write("下午好!朋友!") }
// else if (hour < 19) { document.write("傍晚好!朋友!") }
// else if (hour < 22) { document.write("晚上好!朋友!") }
// else { document.write("夜深了,学习注意眼睛哦!") }


{/* <script language="javascript" type="text/javascript"> */ }
timer('2026-06-22 0:00:00', 'day');

/**
 * 入参第一个为时间字符串,第二个参数为模式选择,如果传入'day',按天数倒计时到秒,不传值,按小时精确到秒
 * @param timeStr
 * @param item
 */
function timer(timeStr, item) {
  setInterval(function () {
    let nowTime = new Date(timeStr) - new Date;
    let minutes = parseInt(nowTime / 1000 / 60 % 60, 10);//计算剩余的分钟
    let seconds = parseInt(nowTime / 1000 % 60, 10);//计算剩余的秒数


    minutes = checkTime(minutes);
    seconds = checkTime(seconds);
    if (item === 'day') {
      let days = parseInt(nowTime / 1000 / 60 / 60 / 24, 10); //计算剩余的天数
      let hours = parseInt(nowTime / 1000 / 60 / 60 % 24, 10); //计算剩余的小时
      days = checkTime(days) - 257;
      hours = checkTime(hours);
      document.getElementById('timer').innerHTML = days + "天" + hours + "小时" + minutes + "分" + seconds + "秒";
    }
    else {
      let hours = parseInt(nowTime / (1000 * 60 * 60), 10); //计算剩余的小时
      hours = checkTime(hours);
      document.getElementById("timer").innerHTML = hours + "小时" + minutes + "分" + seconds + "秒";
    }
  }, 1000);
}

function checkTime(i) { //将0-9的数字前面加上0,例1变为01
  if (i < 10) {
    i = "0" + i;
  }
  return i;
}
